<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<style type="text/css">
	td{
	  padding:5px;
	}
</style>
<script type="text/javascript">
$(document).ready(function(){
	$("#deleteMember").click(function(){
		if($("#adminForm :radio[name=m_id]:checked").length==0){
			alert("삭제할 회원을 선택하세요");
			return; 	
		}

		var flag=confirm("선택된 회원을 삭제하시겠습니까?");
		if(flag){
		if($("#adminForm :radio[name=m_id]:checked").val()=="${sessionScope.loginMember.mvoLogin.m_id}"){
			alert("본인은 삭제할수 없습니다.");
			return;
		}
		$("#adminForm").submit();
		}
	});
	
	$("#detailView").click(function(){
	
		if($("#adminForm :radio[name=m_id]:checked").length==0){
			alert("수정할 회원을 선택하세요");
			return; 	
		}else if(flag=confirm("선택된 회원을 수정하시겠습니까?")){
		
		location.href="member.do?command=getMemberInfo&m_id="+ $(':input:radio[name=m_id]:checked').val() ;
		}   
			
	});
	$("#searchBtn").click(function(){
		if($("#searchByMethod").val()==""){
			alert("검색조건을 선택하세요");
			return;
		}else if($("#searchMember").val()==""){
			alert("검색어를 입력하세요");
			return;
		}
	
		location.href="member.do?command=searchByMemberInfo&searchByMethod="+$("#searchByMethod").val()+"&searchMember="+$("#searchMember").val();	
	});
});
</script>
 
<form action="${initParam.root}/member.do" id="adminForm" method="post" name="adminForm">
<input type="hidden" name="command" value="deleteMemberByAdmin" ><br><br>
<table border=1  align="center" style="border-collapse:collapse;">
	<thead>
		<tr>
		<td>선택</td><td>회원등급</td><td>아이디</td><td>이름</td>
		<td>이메일</td><td>선호음식</td><td>결혼유무</td><td>성별</td>
		</tr>
	</thead>
	<tbody>
	<c:forEach items="${requestScope.searchByMemberInfo.list }" var="mInfo">
	<c:if test="${mInfo.m_id!=null }">
	<tr>
	<td align="center">
	 
	<input type="radio" name="m_id"value="${mInfo.m_id }" id="m_id" ></td>
	<td align="center">
		<c:choose>
			<c:when test="${mInfo.m_type=='b' }">일반회원</c:when>
			<c:otherwise>
				관리자
			</c:otherwise>
		</c:choose>
	</td>
	<td align="center">
			${mInfo.m_id }
	</td><td align="center">${mInfo.m_name }</td>
	<td align="center">${mInfo.m_email }</td>
	<td align="center">${mInfo.m_likeCook }</td>
	<c:choose>
	<c:when test="${mInfo.m_married=='m' }">
		<td align="center">기혼</td>
	</c:when>
	<c:otherwise>
		<td align="center">미혼</td>
	</c:otherwise>
	</c:choose>
			<td align="center">
			<c:choose>
			<c:when test="${mInfo.m_gender=='m' }">
			남
			</c:when>
			<c:otherwise>
			여
			</c:otherwise>
			</c:choose>
			</td>
	</tr>
	</c:if>
	</c:forEach>
		</tbody>
				</table>
	<div align="center"><br>
	<input type="button" value="회원삭제" id="deleteMember" class="button_img"> 
	<input type="button" value="회원 상세정보 보기" id="detailView" class="button_img" style="width: 130px;">
	</div><br> 

<center>
	 <c:if test="${requestScope.searchByMemberInfo.pagingBean.previousPageGroup }">
	 <a href= "${initParam.root }/member.do?command=searchByMemberInfo&pageNo=${requestScope.searchByMemberInfo.pagingBean.startPageOfPageGroup-1}&searchByMethod=${requestScope.searchByMemberInfo.map.searchByMethod}&searchMember=${requestScope.searchByMemberInfo.map.searchMember}">
	 <img src="${initParam.root }/img/paging/left_arrow_btn.gif"></a>
	 </c:if>
	<c:forEach var="i" 	
	begin="${requestScope.searchByMemberInfo.pagingBean.startPageOfPageGroup}"
	 end="${requestScope.searchByMemberInfo.pagingBean.endPageOfPageGroup}">
	 <c:choose>
	 <c:when test="${requestScope.searchByMemberInfo.pagingBean.nowPage!=i}">
	 <a href="${initParam.root }/member.do?command=searchByMemberInfo&pageNo=${i}&searchByMethod=${requestScope.searchByMemberInfo.map.searchByMethod}&searchMember=${requestScope.searchByMemberInfo.map.searchMember}">${i}</a>
	 </c:when>
	 <c:otherwise>
	${i}
	</c:otherwise>
	</c:choose>
	</c:forEach>	 
	 <c:if test="${requestScope.searchByMemberInfo.pagingBean.nextPageGroup}">
	 <a href="${initParam.root }/member.do?command=searchByMemberInfo&pageNo=${requestScope.searchByMemberInfo.pagingBean.endPageOfPageGroup+1}&searchByMethod=${requestScope.searchByMemberInfo.map.searchByMethod}&searchMember=${requestScope.searchByMemberInfo.map.searchMember}">
	 <img src="${initParam.root }/img/paging/right_arrow_btn.gif"></a>
	 </c:if>	 
</center>
	<div align="center">
		<select id="searchByMethod">
			<option value="">---</option>
			<option value="m_id">아이디</option>
			<option value="m_email">이메일</option>
			<option value="m_name">이름</option>
		</select>
		<input type="text" name="searchMember" id="searchMember">
		<input type="button" name="searchBtn" id="searchBtn" value="검색"  class="button_img">
	</div>
</form>


    